from urllib.request import urlopen

url = "http://www.baidu.com"

resp = urlopen(url)

# print(resp.read().decode('utf-8'))
with open('index.html', mode='w', encoding='utf-8') as o_file:
    o_file.write(resp.read().decode('utf-8'))
